package com.xkdx.caipiao.setup;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.xkdx.caipiao.R;

public class HelpActivtiy extends Activity {
	private ListView list_help;
	private HelpAdapter adapter;
	private ImageView back;
	private String[] datas;
	private String[] infos;
	private int[] visiable={0,0,0,0,0,0};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setup_help_caipiao);
		datas=getResources().getStringArray(R.array.help_item);
		infos=getResources().getStringArray(R.array.help_info);
		list_help = (ListView) findViewById(R.id.lv_help);
		back = (ImageView) findViewById(R.id.help_back);
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		adapter = new HelpAdapter(this);
		list_help.setAdapter(adapter);
		list_help.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				TextView tv=(TextView)view.findViewById(R.id.help_info);
				if(visiable[position]==0){
					visiable[position]=1;
					tv.setVisibility(View.VISIBLE);
				}else{
					visiable[position]=0;
					tv.setVisibility(View.GONE);
				}
				
				
			}
		});
	}

	class HelpAdapter extends BaseAdapter {

		private Context context;

		public HelpAdapter(Context context) {
			this.context = context;
		}

		@Override
		public int getCount() {

			return datas.length;
		}

		@Override
		public Object getItem(int position) {

			return datas[position];
		}

		@Override
		public long getItemId(int position) {

			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			View view;

			ViewHoler viewholer;
			if (convertView != null) {
				view = convertView;
				viewholer = (ViewHoler) view.getTag();
			} else {
				viewholer = new ViewHoler();
				view = View.inflate(getApplicationContext(),
						R.layout.setp_help_item_caipiao, null);
				viewholer.name = (TextView) view
						.findViewById(R.id.tv_help_name);
				viewholer.info=(TextView)view.findViewById(R.id.help_info);
				view.setTag(viewholer);

			}
			viewholer.name.setText(datas[position]);
			viewholer.info.setText(infos[position]);

			return view;
		}

		class ViewHoler {
			TextView name,info;
		}

	}
}
